package org.evolAI.organism.service;

import org.evolAI.organism.dao.OrganismDAO;
import org.evolAI.organism.domain.Organism;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("organismService")
@Transactional(readOnly=true)
public class OrganismServiceImpl implements OrganismService {

	@Autowired
	OrganismDAO organismDao;

	@Override
	@Transactional(propagation=Propagation.REQUIRED, readOnly=false)
	public void addOrganism(Organism organism) {
		organismDao.addOrganism(organism);
	}

	@Override
	@Transactional(propagation=Propagation.REQUIRED, readOnly=false)
	public void saveOrganism(Organism organism) {
		if(organism.getId() == null) {
			organismDao.addOrganism(organism);
		} else {
			organismDao.saveOrganism(organism);
		}
	}

}
